"设置编码
set encoding=utf-8
set fileencodings=utf-8,chinese,latin-1
if has("win32")
set fileencoding=chinese
else
set fileencoding=utf-8
endif
" 设置文件编码检测类型及支持格式
set fencs=utf-8,gbk,ucs-bom,gb18030,gb2312,cp936
" 指定菜单语言
set langmenu=zh_CN.utf-8
source $VIMRUNTIME/delmenu.vim
source $VIMRUNTIME/menu.vim

"帮助语言
set helplang=cn
set iskeyword =

set nocompatible
filetype off
set rtp+=~/.vim/bundle/vundle/
call vundle#begin()

Plugin 'gmarik/vundle'
Plugin 'a.vim'
Plugin 'The-NERD-Commenter'
Plugin 'The-NERD-tree'
Plugin 'matchit.zip'
Plugin 'taglist.vim'
Plugin 'FencView.vim'
Plugin 'c.vim'
Plugin 'Mark'
Plugin 'ShowMarks'
Plugin 'Command-T'
Plugin 'bufexplorer.zip'
Plugin 'rainbow_parentheses.vim'
Plugin 'YankRing.vim'
Plugin 'cpp.vim'
Plugin 'loadtags'
Plugin 'Vitality'
Plugin 'statusline.vim'
Plugin 'vimux'
Plugin 'copycppdectoimp.vim'
Plugin 'headerGatesAdd.vim'
Plugin 'google.vim'
Plugin 'SirVer/ultisnips'
Plugin 'honza/vim-snippets'
Plugin 'EasyGrep'
Plugin 'fugitive.vim'
Plugin 'commentary.vim'
Plugin 'octol/vim-cpp-enhanced-highlight'
Plugin 'Tabular'
Plugin 'slimv.vim'
Plugin 'AutoTag'
Plugin 'gtags.vim'
Plugin 'git://github.com/kana/vim-operator-user.git'
Plugin 'git://github.com/Shougo/vimproc.vim.git'
Plugin 'git://github.com/rhysd/vim-clang-format.git'
Plugin 'HTML.zip'
Plugin 'Css-Pretty'
Plugin 'CSS3-Highlights'
Plugin 'git://github.com/jimenezrick/vimerl.git'

call vundle#end()

filetype plugin indent on
"filetype off
"call pathogen#runtime_append_all_bundles()
"filetype plugin indent on


"au syntax * cal rainbow#activate()

set fileformats=unix,dos
set nocompatible
set modelines=0

set tabstop=2
set shiftwidth=2
set softtabstop=2
set expandtab

"set encoding=utf-8
"set fileencoding=utf-8
set scrolloff=3
set autoindent
set cino+=(0,W4
set showmode
set autoread
set hidden
set wildmenu
set wildmode=list:longest
set visualbell
set noeb
set cursorline

set ttyfast
set backspace=indent,eol,start
set laststatus=2
set undofile
set autochdir
set go-=T

"let mapleader=","


nnoremap / /\v
vnoremap / /\v
set ignorecase
set smartcase
set gdefault
set incsearch
set showmatch
set hlsearch
"set bomb

nnoremap <silent> <leader>t :CommandT<CR>
nnoremap <silent> <leader>b :CommandTBuffer<CR>
"map <leader>n :NERDTreeToggle<CR>
nnoremap <leader><space> :noh<cr>
nnoremap <tab> %
vnoremap <tab> %

nnoremap <silent> <F10> :%s///g<CR>

set wrap
"set textwidth=79
set formatoptions=qrn1
set colorcolumn=85
set list
set listchars=tab:▸\ ,eol:¬

nnoremap <up> <nop>
nnoremap <down> <nop>
nnoremap <left> <nop>
nnoremap <right> <nop>
inoremap <up> <nop>
inoremap <down> <nop>
inoremap <left> <nop>
inoremap <right> <nop>
nnoremap j gj
nnoremap k gk
inoremap <F1> <ESC>
nnoremap <F1> <ESC>
vnoremap <F1> <ESC>

"nnoremap ; :
au FocusLost * :wa
nnoremap <leader>W :%s/\s\+$//<cr>:let @/=''<CR>
"nnoremap <leader>q gqip
nnoremap <leader>v V`]
nnoremap <leader>ev <C-w><C-v><C-l>:e $MYVIMRC<cr>
inoremap jj <ESC>
nnoremap <leader>w <C-w>v<C-w>l
nnoremap <C-h> <C-w>h
nnoremap <C-j> <C-w>j
nnoremap <C-k> <C-w>k
nnoremap <C-l> <C-w>l
nnoremap <silent> <F3> :YRShow<cr>
inoremap <silent> <F3> <ESC>:YRShow<cr>
colo koehler
"colo molokai
set noflash
set tags=~/work/magicworld_server_dev/tags;

let c_no_curly_error=1
nnoremap  <C-s> :tnext<CR>

set novisualbell
augroup filetype
  au! BufRead,BufNewFile *.proto setfiletype proto
augroup end

augroup filetype
  au! BufRead,BufNewFile *.go setfiletype go
augroup end


command SetGLSLFileType call SetGLSLFileType()
function SetGLSLFileType()
  for item in getline(1,10)
    if item =~ "#version 400"
      execute ':set filetype=glsl400'
      break
    endif
    if item =~ "#version 330"
      execute ':set filetype=glsl330'
      break
    endif
  endfor
endfunction
au BufNewFile,BufRead *.frag,*.vert,*.fp,*.vp,*.glsl SetGLSLFileType

let g:ackprg="ack-grep -H --nocolor --nogroup --column"

"powerline {
set t_Co=256
let g:Powerline_symbols = 'fancy'

"}

if $VIM_HATE_SPACE_ERRORS != '0'
    let c_space_errors=1
endif
noremap <F7> :Autoformat<CR><CR>
syntax on

function RemoveTrailingWhitespace()
    if &ft != "diff"
        let b:curcol = col(".")
        let b:curline = line(".")
        silent! %s/\s\+$//
        silent! %s/\(\s*\n\)\+\%$//
        call cursor(b:curline, b:curcol)
    endif
endfunction
autocmd BufWritePre * call RemoveTrailingWhitespace()


au VimEnter * RainbowParenthesesToggle
au Syntax * RainbowParenthesesLoadRound
au Syntax * RainbowParenthesesLoadSquare
au Syntax * RainbowParenthesesLoadBraces

 " conceal in insert (i), normal (n) and visual (v) modes
" set concealcursor=inv
 " hide concealed text completely unless replacement character is defined
" set conceallevel=2
set autowriteall
set path+=~/work/magicworld_server_dev
set linespace=0
"nnoremap lx :VimuxCloseRunner<cr>
"nnoremap lp :VimuxPromptCommand<cr>
"nnoremap ll :VimuxRunLastCommand<cr>
"nnoremap lu :VimuxScrollUpInspect<cr>
"nnoremap ld :VimuxScrollDownInspect<cr>




function! UpdateCtags()
  let curdir=getcwd()
  while !filereadable("./tags")
    cd ..
    if getcwd() == "/"
      break
    endif
  endwhile
  if filewritable("./tags")
    !/usr/bin/ctags -R --file-scope=yes --langmap=c:+.h --languages=c,c++ --links=yes --c-kinds=+p --c++-kinds=+p --fields=+iaS --extra=+q
    TlistUpdate
  endif
  execute ":cd " . curdir
endfunction

"nnoremap <F10> :call UpdateCtags()<cr>


"*****************************************************************
"" GHPH Options: {{{
"*****************************************************************
"" See copycppdectoimp.vim for more documtation.
" Virtual: 1 for commented, else removed.
let g:ghph_ShowVirtual                    = 1
" " Static:  1 for commented, else removed.
let g:ghph_ShowStatic                     = 1
" " Default Params: 3 for /*5*/, 2 for /* = 5*/, else removed.
let g:ghph_ShowDefaultParams     = 2
" " Command: 1 to define :GHPH (default if nothing defined), 0 to NOT define.
let g:ghph_useGHPH                       = 1
" " Command: 1 to define :GH and :PH, 0 to NOT define.
let g:ghph_useGHandPH               = 1
" " }}}
"
nnoremap <F9> :cn<cr>

let g:HeaderGatesAdd_prefix="FND_"
let g:HeaderGatesAdd_gate_type=1

set vb t_vb=

set makeprg=cd\ ~/work/magicworld_server_dev/build\ &&\ make\ -j2


map <C-K> :pyf /home/fndisme/tool/llvm/tools/clang/tools/clang-format/clang-format.py<CR>
imap <C-K> <ESC>:pyf /home/fndisme/tool/llvm/tools/clang/tools/clang-format/clang-format.py<CR>i

"map <C-K> :ClangFormat<CR>
"imap <C-K> <ESC>:ClangFormat<CR>i



source ~/.vim/bundle/AutoTag/plugin/autotag.vim

let Gtags_Auto_Map = 1
